/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andre
 */
@Entity
@Table(name = "funcionario")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Funcionario.findAll", query = "SELECT f FROM Funcionario f"),
    @NamedQuery(name = "Funcionario.findByDataAdmissao", query = "SELECT f FROM Funcionario f WHERE f.dataAdmissao = :dataAdmissao"),
    @NamedQuery(name = "Funcionario.findByDataDemissao", query = "SELECT f FROM Funcionario f WHERE f.dataDemissao = :dataDemissao"),
    @NamedQuery(name = "Funcionario.findByDataInclusao", query = "SELECT f FROM Funcionario f WHERE f.dataInclusao = :dataInclusao"),
    @NamedQuery(name = "Funcionario.findBySalario", query = "SELECT f FROM Funcionario f WHERE f.salario = :salario")})
public class Funcionario extends Pessoa implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataAdmissao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataAdmissao;
    
    @Column(name = "dataDemissao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataDemissao;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataInclusao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataInclusao;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "salario")
    private double salario;
    
    @JoinColumn(name = "idFuncao", referencedColumnName = "idFuncao")
    @ManyToOne
    private Funcao funcao;
    
    @ManyToMany(mappedBy="funcionarios")
    private List<Folha> folhas;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "responsavel")
    private List<Contrato> contratoList;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "professor")
    private List<Turma> turmaList;

    public Funcionario() {
        super();
    }

    public Funcionario(Date dataAdmissao, Date dataInclusao, double salario) {
        this.dataAdmissao = dataAdmissao;
        this.dataInclusao = dataInclusao;
        this.salario = salario;
    }
    
    public Funcionario(String nome, String cgc, String tipoPessoa, Date dataAdmissao, Date dataInclusao){
        super(nome, cgc, tipoPessoa);
        this.dataAdmissao = dataAdmissao;
        this.dataInclusao = dataInclusao;
    }

    public Date getDataAdmissao() {
        return dataAdmissao;
    }

    public void setDataAdmissao(Date dataAdmissao) {
        this.dataAdmissao = dataAdmissao;
    }

    public Date getDataDemissao() {
        return dataDemissao;
    }

    public void setDataDemissao(Date dataDemissao) {
        this.dataDemissao = dataDemissao;
    }

    public Date getDataInclusao() {
        return dataInclusao;
    }

    public void setDataInclusao(Date dataInclusao) {
        this.dataInclusao = dataInclusao;
    }

    public double getSalario() {
        return salario;
    }

    public void setSalario(double salario) {
        this.salario = salario;
    }

    @XmlTransient
    public List<Contrato> getContratoList() {
        return contratoList;
    }

    public void setContratoList(List<Contrato> contratoList) {
        this.contratoList = contratoList;
    }

    @XmlTransient
    public List<Turma> getTurmaList() {
        return turmaList;
    }

    public void setTurmaList(List<Turma> turmaList) {
        this.turmaList = turmaList;
    }

    /**
     * @return the funcoes
     */
    public Funcao getFuncao() {
        return funcao;
    }

    /**
     * @param funcoes the funcoes to set
     */
    public void setFuncao(Funcao funcao) {
        this.funcao = funcao;
    }

    /**
     * @return the folhas
     */
    public List<Folha> getFolhas() {
        return folhas;
    }

    /**
     * @param folhas the folhas to set
     */
    public void setFolhas(List<Folha> folhas) {
        this.folhas = folhas;
    }

}
